home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
comm
/
tcp
/
SLIPScripts1_3.lha
/
SLIPStart.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-02-03
|
7KB
|
163 lines
/* SLIPStart.rexx ver 1.3 Feb. 3, 1995 by Travis Pascoe */
/* pasc8891@raven.csrv.uidaho.edu */
/* */
/* SLIPStart is an ARexx script used to connect to a host with */
/* dynamic slip IP assignment and initialize the AmiTCP stack. */
/* The script is based on a script by Bradley Tinder with several */
/* blatant errors and bugs removed (sorry Bradley). [Bradley was */
/* inspired by Dave Bolen's REXX/2 SLIPUP.CMD for IBM OS/2.] */
/* This script is intended mainly as a model and an example for */
/* automating SLIP dialup. */
/* */
/* Requirements: ARexx (obviously) */
/* rexxserdev.library ver 5.02+ (see Aminet) */
/* by Joseph M. Stivaletta */
/* AmiTCP ver 3.0b+ */
/* */
/* Usage: From a cli, type: rx slipstart */
/* */
/* Warning: You WILL need to modify the script in several */
/* places to suit your host dialup terminal. */
/* Follow the comments below for assistance. */
/* The example below works with my university's */
/* Xylogics terminal server. */
if ~show('L',"rexxsupport.library") then
if ~addlib('rexxsupport.library', 0, -30, 0) then exit 41
if ~show('L', "rexxserdev.library") then
if ~addlib( 'rexxserdev.library', 0, -30, 0) then exit 42
signal on break_c
cr = '0d'x
initstr1 = 'ATZ'||cr /* modem init, change as desired */
initstr2 = 'AT&D0'||cr /* set ignore carrier detect !! */
dialstr = 'atdt555-1234'||cr /* number to dial */
slip_cmd = '30'||cr /* selection number for SLIP */
username = 'myname'||cr /* change to your account name */
passwd = 'mypassword'||cr /* change to your account passwd */
dh = SerOpen('serial.device', 0)
if (dh == 0) then do; say 'Cannot open serial.device'; exit 43; end
check = SerClear(dh)
/* I use 38400 modem-computer speed, change as desired */
check = SerSetParms(dh, 38400, 8, N, 1, 0, 250000, 4096)
buffer = AllocMem(4096)
junk = c2d(buffer)
check = 0
connected = 0 /* flag for modem connection -- suggested by */
/* _Bucky_ of IRC fame. */
/* (makes ctrl-c breaks a little cleaner...thanks) */
say 'Dialing SLIP service... '
SerWrite(dh, initstr1, length(initstr1))
Delay(200)
SerWrite(dh, initstr2, length(initstr2))
do forever /* loop until connect, use ctrl-c to break out */
delay(100)
if (check == 0) then
do
result = SerWrite(dh, dialstr, length(dialstr))
check = 1
totalstr = ''
end
status = SerQuery(dh)
parse upper var status valid bytes_read .
rcvdstrg = SerRead(dh, junk, bytes_read)
totalstr = totalstr||rcvdstrg
check = modem_query(totalstr)
if (check == 100) then leave
if (check == 101) then do; check = 0; say 'BUSY'; end
if (check == 102) then do; check = 0; say 'NO CARRIER'; end
end
connect = 1
parse var totalstr .'CONNECT ' speed+5 +2 totalstr
say 'Connected at '||speed||'.'
call wait_str(']:') /* these chars signal the first terminal */
/* prompt, change as needed */
SerWrite(dh, slip_cmd, length(slip_cmd))
say 'SLIP selection made.'
call wait_str('Username: ') /* wait for username prompt, change */
/* as needed */
SerWrite(dh, username, length(username))
say 'Username sent.'
call wait_str('Password: ') /* wait for password prompt, change */
/* as needed */
SerWrite(dh, passwd, length(passwd))
say 'Password sent.'
call wait_str('Annex') /* annex string signals the line */
/* that contains the dynamic IP */
SerClose(dh)
/* the parse command below extracts the IP address from rcvdstr, */
/* change as needed (should work with variable length IPs now) */
parse var rcvdstr . 'Your address is ' a '.' b '.' c '.' d '.'.
slip_ip = a||'.'||b||'.'||c||'.'||d
say 'Current SLIP address is: '||slip_ip
time_ip = time('c')||' '||date()
say 'Connect time: '||time_ip
address command
'setenv ip '||slip_ip /* ip is the current dynamic IP */
'setenv iptime '||time_ip /* iptime is the connect time */
'copy ENV:ip ENVARC:oldip' /* save ip as oldip for SLIPresume */
'copy ENV:iptime ENVARC:oldiptime'
/* I use cslip and 38400 modem-computer speed, change as desired */
'echo >ENV:sana2/rhcslip0.config "serial.device 0 38400 $ip"'
/* change hostname and alias as desired */
'echo >AmiTCP:db/netdb-myhost "HOST $ip me.mydomain.edu me"'
/* change domain as needed */
'echo >>AmiTCP:db/netdb-myhost "DOMAIN 129.123.45.6"'
/* change nameserver as needed */
'echo >>AmiTCP:db/netdb-myhost "NAMESERVER 129.123.123.4"'
'startnet'
/* if using rhslip above, use rhslip here also otherwise rhcslip */
'online rhcslip.device 0'
call FreeMem(buffer,4096)
exit 0
/* Exit point for "Break C" or ^C */
/*----------------------------------------*/
break_c:
say '***Break'
if connected ~= 0 then /* Thanks again _Bucky_ 8) */
do
say 'Hanging up modem.'
check = SerWrite(dh, '+++', 3)
check = Delay(100)
check = SerWrite(dh, 'ATH0'||cr , 5)
end
SerClose(dh)
FreeMem(buffer,4096)
exit 20
/* wait_str returns when arg is received */
/* ---------------------------------------*/
wait_str:
teststr = arg(1)
check = 0
do until (check ~= 0)
status = SerQuery(dh)
parse upper var status valid bytes_read .
rcvdstr = SerRead(dh, junk, bytes_read)
totalstr = totalstr||rcvdstr
check = pos(teststr,totalstr)
Delay(20)
end
rcvdstr = totalstr
totalstr = ''
return 0
/* modem_query determine modem status */
/*----------------------------------------*/
modem_query:
teststr = arg(1)
if (pos('CONNECT' , teststr) ~= 0) then return 100
if (pos('BUSY' , teststr) ~= 0) then return 101
if (pos('NO CARRIER', teststr) ~= 0) then return 102
return 200